﻿using System;
using System.Threading;
using EntityMapping.Models;
using FluentPS.Services.Impl;

namespace EntityMapping
{
    public class ProjectMappingTest
    {
        private Guid testProjectUid = new Guid("{0c904572-e1fb-44e3-8109-e62730be2e38}"); // set your project UID here

        public void Run()
        {
            var logService = new LogService();
            var sessionService = new SessionService();
            var lookupTableService = new LookupTableService(sessionService, logService);
            var projectsService = new PSProjectService<Project>(logService, sessionService, lookupTableService);

            Console.WriteLine(string.Format("Load project by id: {0}", testProjectUid));

            var project = projectsService.Get(testProjectUid);

            Console.WriteLine(string.Format("Sample Assumptions: {0}", project.SamplePrimaryObjectives));

            /*project.SampleAssumptions = string.Format("{0} updated", project.SampleAssumptions);

            Console.WriteLine("Update project");

            var queueService = new PSQueueSystemService(logService, sessionService);
            var jobId = projectsService.CheckIn(project.Uid, Guid.NewGuid());
            // wait for queue
            queueService.WaitForQueue(jobId);

            Guid sessionId = Guid.NewGuid();
            projectsService.CheckOut(project.Uid, sessionId);

            jobId = projectsService.Update(project, sessionId);
            queueService.WaitForQueue(jobId);

            jobId = projectsService.Publish(project.Uid, false);
            queueService.WaitForQueue(jobId);

            jobId = projectsService.CheckIn(project.Uid, Guid.NewGuid());
            queueService.WaitForQueue(jobId);
            */
            Console.WriteLine("Exit");
        }
    }
}
